# 拉取 image
FROM ubuntu:23.04
# Dockerfile 作者信息
MAINTAINER hsdnmzz@163.com
# 指定变量
ARG pack="apt"
ARG installc="${pack} install"
ARG updatec="${pack} update"
ARG createUserName="javac"
ARG createPassword="Hsd052210Nm"
ARG sudoSource="/etc/sudoers"
ARG debHost="http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/"
ARG sourceListPath="/etc/apt/sources.list"
ARG JavaPath="/lib/jvm/java-1.17.0-openjdk-arm64"
# 配置国内软件源
RUN mv ${sourceListPath} ${sourceListPath}.backup
RUN echo "deb ${debHost} lunar main restricted universe multiverse" >> ${sourceListPath}.temp
RUN echo "deb ${debHost} lunar-updates main restricted universe multiverse" >> ${sourceListPath}.temp
RUN echo "deb ${debHost} lunar-backports main restricted universe multiverse" >> ${sourceListPath}.temp
RUN echo "deb ${debHost} lunar-security main restricted universe multiverse" >> ${sourceListPath}.temp
RUN mv ${sourceListPath}.temp ${sourceListPath}
RUN chmod 777 ${sourceListPath}
# 创建用户
RUN useradd ${createUserName}
RUN echo ${createUserName}:${createPassword} | chpasswd
RUN echo "${createUserName} ALL=(ALL:ALL) ALL" >> ${sudoSource}
# 安装必要的包
RUN apt update
RUN ${installc} openjdk-17-jdk -y
RUN ${installc} vim -y
RUN ${installc} net-tools -y
RUN ${installc} sudo -y
RUN ${installc} python -y
RUN ${installc} zsh -y
RUN ${installc} git -y
RUN ${installc} wget -y
# 修改默认 Shell
RUN chsh -s /bin/zsh
RUN chsh -s /bin/zsh ${createUserName}
# 配置环境变量
ENV JAVA_HOME ${JavaPath}
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV PATH $PATH:$JAVA_HOME/bin
# 指定用户
USER ${createUserName}
# 指定工作路径
WORKDIR /home/${createUserName}
